package com.wicket.okroperation.web.contorller;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.page.PageMethod;
import com.wicket.okroperation.biz.service.DeploymentService;
import com.wicket.okroperation.biz.service.dto.req.*;
import com.wicket.okroperation.biz.service.dto.res.*;
import com.wicket.okroperation.common.ro.OkrResult;
import com.wicket.okroperation.common.util.CommonFunctionHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@RestController
@RequestMapping("/operation/deployment/")
public class DeploymentController {

  @Autowired
  DeploymentService deploymentService;
/**
   * D6修改数据分离
   */
    @PostMapping("updateDataSeparation")
    public OkrResult<UpdateDataSeparationRespDto> updateDataSeparation(@RequestBody @Validated UpdateDataSeparationReqDto reqDTO){
    return OkrResult.success(deploymentService.updateDataSeparation(reqDTO));
    }
/**
   * D6查询数据分离列表
   */
    @PostMapping("queryDataSeparationList")
    public OkrResult<QueryDataSeparationListRespDto> queryDataSeparationList(@RequestBody @Validated QueryDataSeparationListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryDataSeparationListRespDto retData = deploymentService.queryDataSeparationList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);

    }
/**
   * D6查询数据分离详情
   */
    @PostMapping("queryDataSeparationDetail")
    public OkrResult<QueryDataSeparationDetailRespDto> queryDataSeparationDetail(@RequestBody @Validated QueryDataSeparationDetailReqDto reqDTO){
    return OkrResult.success(deploymentService.queryDataSeparationDetail(reqDTO));
    }
/**
   * D6判断数据分离
   */
    @PostMapping("judgeDataSeparation")
    public OkrResult<JudgeDataSeparationRespDto> judgeDataSeparation(@RequestBody @Validated JudgeDataSeparationReqDto reqDTO){
    return OkrResult.success(deploymentService.judgeDataSeparation(reqDTO));
    }
}
